import serial



ser = serial.Serial("com3", baudrate=57600, timeout=0.1)



# 试试看是不是因为按字符接收并处理的原因，导致的字符丢失
# 看样子确实是我的接收程序没写好
i = 0
while True:
    i += 1
    if i % 1000 == 0:
        print(i)
    
    ss = ser.readline()
    
    values = ss.strip()[1:-1].split(b":")
    values = values[-1].split(b',')
    try:
        values = [float(x) for x in values]
    except ValueError:
        print("ValueError |",ss, values)
        
    if ss != b'<pid:1.00,2.00,3.00,4.00>\r\n' or values != [1.0, 2.0, 3.0, 4.0]:
        print(i, ss)
        
        



